package com.cattsoft.user.service.commonimpl;

import java.util.List;

import com.cattsoft.user.model.User;
import com.cattsoft.user.service.IUserService;
import com.cattsoft.util.common.exception.OssApplicationException;
import com.cattsoft.util.common.service.IGenericService;
 
public class UserServiceImpl implements IUserService {
			
	private IGenericService service;
	
	public void delete(User user) {		 
		try {
			service.DeleteByID(User.class, user.getId());
		} catch (OssApplicationException e) {
			e.printStackTrace();
		}
	}

	public List findAll() {
		try {
			return service.getByHql("from User");
		} catch (OssApplicationException e) {
			e.printStackTrace();
		}
		return null;
	}

	public User findById(Integer id) {
		try {
			return (User)service.getByID(User.class, id);
		} catch (OssApplicationException e) {
			e.printStackTrace();
		}
		return null;
	}

	public void save(User user) {
		try {
			service.SaveData(user);
		} catch (OssApplicationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void update(User user) {		 
		try {
			service.SaveData(user);
		} catch (OssApplicationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public IGenericService getService() {
		return service;
	}

	public void setService(IGenericService service) {
		this.service = service;
	}
	
	 
}
